package com.zx.erp.purchase.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zx.erp.purchase.bean.CBrand;
import com.zx.erp.purchase.bean.CPurchase;
import com.zx.erp.purchase.bean.PurchaseCondition;
import com.zx.erp.purchase.service.CPurchaseService;
import com.zx.erp.sys.bean.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 胡展旺
 * @since 2021-11-10
 */
@Controller
@RequestMapping("/purchase/c-purchase")
public class CPurchaseController {

    @Autowired
    private CPurchaseService service;

    @RequestMapping("/lists")
    public String Lists(HttpSession session, PurchaseCondition conn ,Model model, @RequestParam(value = "pageno", defaultValue = "1") Integer
            pageNo){
        Users users = (Users) session.getAttribute("users");
        Integer pageSize = 6;
        Page<CPurchase> pageInfo = service.getPurchaseListByCondition(conn, pageNo, pageSize,users);
        model.addAttribute("CgPin",pageInfo);
        return "forward:/purchase/purchase/purchaseList.html";
    }

}

